package com.ylkj.bus.dispatcher;

import com.ylkj.Application;
import com.ylkj.bus.MessageContent;
import com.ylkj.bus.dispatcher.handler.DeviceOnlineDataStreamHandler;
import org.apache.flink.streaming.api.datastream.DataStream;

import java.util.Properties;

/**
 * @Author: wengzx
 * @Date: 2025/4/21
 * @Desc:
 */
public enum DispatcherHandler {
    //处理数据供用采使用
    IOT_ONLINE_STATUS_DATA {
        @Override
        protected IStreamHandler getHandler(Properties flinkProperties) {
            String tableName = flinkProperties.getProperty("sink.rds.tableName");
            String tableName2 = flinkProperties.getProperty("sink.rds.tableName2");
            String tableName3 = flinkProperties.getProperty("sink.rds.tableName3");
            String tableName4 = flinkProperties.getProperty("sink.rds.tableName4");
            String tableName5 = flinkProperties.getProperty("source.rds.tableName5");
            String tableName6 = flinkProperties.getProperty("source.rds.tableName6");
            return new DeviceOnlineDataStreamHandler(
                    tableName,
                    Application.getRdsConfig(flinkProperties),
                    Application.getRedisConfig(flinkProperties),
                    tableName2,
                    tableName3,
                    tableName4,
                    tableName5,
                    tableName6,
                    Application.getRedisConfig1(flinkProperties)
            );
        }
    };

    protected abstract IStreamHandler getHandler(Properties flinkProperties);

    public void dispatch(DataStream<MessageContent> stream, Properties flinkProperties) {
        getHandler(flinkProperties).handle(stream);
    }
}
